package net.wanho.client;

import net.wanho.config.MyLoadBalancerConfig;
import net.wanho.entity.User;
import net.wanho.vo.AjaxResult;
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClients;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * Author：汤小洋
 * Date：2025-02-13 15:50
 * Description：<描述>
 */
// @FeignClient("user-provider")
@FeignClient(value = "cloud-gateway", path = "/api/v2", fallback = UserClientFallback.class) // 指定请示前缀
@LoadBalancerClients(defaultConfiguration = {MyLoadBalancerConfig.class}) // 指定负载均衡配置
public interface UserClient {

    @GetMapping("/user/test")
    String test();

    /**
     * 传递参数时，必须添加注解
     */
    @GetMapping("/user")
    AjaxResult findByName(@RequestParam("name") String name); // 这里必须指定value

    @DeleteMapping("/user/{id}")
    AjaxResult removeById(@PathVariable("id") Integer id);

    @PostMapping("/user")
    AjaxResult addUser(@RequestBody User user);

    @PutMapping("/user")
    AjaxResult modifyUser(@RequestBody User user);

    /**
     * 如果是普通对象，不能直接传递，使用Map传参
     */
    @GetMapping("/user/query")
    AjaxResult query(@RequestParam Map<String, Object> params);
}
